package work20241206_chap7.a_abstract;

/**
 * @author zdl
 * @date 2024/12/6
 */
abstract class Animal{
    public abstract void drink();
}
abstract class Person extends Animal{
    private String name;
    private int age;
    public abstract void eat();
    public void sleep(){
        System.out.println("睡觉");
    }

    @Override
    public void drink() {
        System.out.println("喝饮料");
    }

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "Person{name = " + name + ", age = " + age + "}";
    }
}
class Man extends Person{

    @Override
    public void eat() {
        System.out.println("Man吃牛肉");
    }

    @Override
    public void drink() {
        System.out.println("Man喝啤酒");
    }
}
public class Demo {
    public static void main(String[] args) {
        Person person = new Man();
        person.setName("大力");
        person.setAge(22);
        person.eat();
        person.drink();
        System.out.println(person);
    }
}
